//
//  HotLineTableViewCell.m
//  LubanWork
//
//  Created by xiaotong on 2020/1/2.
//  Copyright © 2020 xiaohao. All rights reserved.
//

#import "HotLineTableViewCell.h"

@implementation HotLineTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = ColorWhite;
        [self.contentView addSubview:self.HotLineLab];
        [self.contentView addSubview:self.TypeImge];
        [self.contentView addSubview:self.numberLab];
        [self.contentView addSubview:self.copyBtn];
        
        [self.HotLineLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.left.equalTo(self.contentView).offset(kSCRATIO(25.5));
            make.width.mas_offset(kSCRATIO(80));
            make.height.mas_offset(kSCRATIO(15));
        }];
        
        
        [self.TypeImge mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.left.equalTo(self.HotLineLab.mas_right).offset(kSCRATIO(20));
            make.height.width.mas_offset(kSCRATIO(20));
        }];
        
        
        [self.numberLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.left.equalTo(self.TypeImge.mas_right).offset(kSCRATIO(5));
            make.height.mas_offset(kSCRATIO(10));
            make.width.mas_offset(kSCRATIO(90));
        }];
        
        
        [self.copyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.equalTo(self.contentView.mas_right).offset(-kSCRATIO(25));
            make.width.mas_offset(kSCRATIO(65));
            make.height.mas_offset(kSCRATIO(25));
        }];
    }
    return self;
}

-(UILabel *)HotLineLab{
    if (!_HotLineLab) {
        _HotLineLab = [UILabel CreatLabeltext:@"报名联系方式" Font:kFONT(12) Textcolor:kColorFromRGBHex(0x666666) textAlignment:NSTextAlignmentLeft];
    }
    return _HotLineLab;
}

-(UIImageView *)TypeImge{
    if (!_TypeImge) {
        _TypeImge = [[UIImageView alloc] init];
        _TypeImge.image = [UIImage imageNamed:@"WeChat"];
    }
    return _TypeImge;
}


-(UILabel *)numberLab{
    if (!_numberLab) {
        _numberLab = [UILabel CreatLabeltext:@"88888888888" Font:kFONT(12) Textcolor:kColorFromRGBHex(0x666666) textAlignment:NSTextAlignmentLeft];
    }
    return _numberLab;
}

-(UIButton *)copyBtn{
    if (!_copyBtn) {
        _copyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_copyBtn setTitle:@"复制号码" forState:UIControlStateNormal];
        _copyBtn.titleLabel.font = kFONT(12);
        [_copyBtn addTarget:self action:@selector(copyClick) forControlEvents:UIControlEventTouchUpInside];
        [_copyBtn setTitleColor:ColorWhite forState:UIControlStateNormal];
        [_copyBtn setBackgroundColor:kColorFromRGBHex(0x775FFB)];
        ViewRadius(_copyBtn, kSCRATIO(5));
        
    }
    return _copyBtn;
}
-(void)copyClick{
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = self.numberLab.text;
    [HWProgressHUD showMessage:@"复制成功"];
}


@end
